package com.example.movie.ui.user.order

import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.NavUtils
import com.example.movie.R
import com.example.movie.common.constants.Constants
import com.example.movie.data.user.factory.UserViewModelFactory
import com.example.movie.data.user.model.OrderViewModel
import com.example.movie.ui.user.adapter.OrderPagerAdapter
import com.example.movie.utils.ContextHolder
import kotlinx.android.synthetic.main.fragment_order.*
import kotlinx.android.synthetic.main.fragment_person_page.toolbar

class OrderActivity : AppCompatActivity() {

    private val orderViewModel: OrderViewModel by viewModels(factoryProducer = { UserViewModelFactory() })

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.fragment_order)
        orderViewModel.startObserveOrderSate()
        toolbar.setNavigationOnClickListener {
            ContextHolder.getMainContext().location = Constants.JumpAction.toUserFragment
            NavUtils.navigateUpFromSameTask(this@OrderActivity)
        }
        val sectionsPagerAdapter = OrderPagerAdapter(this, supportFragmentManager)
        order_view_pager.adapter = sectionsPagerAdapter
        order_tabs.setupWithViewPager(order_view_pager)
    }

}